<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>短信设置</title>
    <link rel="stylesheet" href="/static/public/layui/css/layui.css">
    <script type="text/javascript" src="/static/public/layui/layui.js"></script>
</head>
<body style="padding: 15px">
<div class="layui-card">
    <div class="layui-card-header">短信设置</div>
    <div class="layui-card-body">
        <form class="layui-form">
            @csrf
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 103px">AccessKeyID</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" name="key" value="{{$setting['vals']['key']}}">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 103px">AccessKeySecret</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" name="secret" value="{{$setting['vals']['secret']}}">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 103px">签名</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" name="signname" value="{{$setting['vals']['signname']}}">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" style="width: 103px">模板ID</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" name="code" value="{{$setting['vals']['code']}}">
                </div>
            </div>
            <div class="layui-input-block">
                <button type="button" class="layui-btn" onclick="save()">保存</button>
            </div>
        </form>
    </div>
</div>


<script type="text/javascript">
    layui.use(['layer'],function(){
        layer = layui.layer;
        $ = layui.jquery;
    });

    function save(){
        var key = $.trim($('input[name="key"]').val());
        var secret = $.trim($('input[name="secret"]').val());
        var signname = $.trim($('input[name="signname"]').val());
        var code = $.trim($('input[name="code"]').val());
        if(key==''){
            return layer.alert('AccessKeyID不能为空',{icon:2});
        }
        if(secret==''){
            return layer.alert('AccessKeySecret不能为空',{icon:2});
        }
        if(signname==''){
            return layer.alert('签名不能为空',{icon:2});
        }
        if(code==''){
            return layer.alert('模板ID不能为空',{icon:2});
        }
        $.post('/admin/setting/short_save',$('form').serialize(),function(res){
            if(res.code>0){
                return layer.alert(res.msg,{icon:2});
            }
            layer.msg(res.msg);
        },'json');
    }
</script>
</body>
</html>
